package com.mall.dao;

import com.mall.domain.*;

import org.apache.ibatis.annotations.*;


import java.util.List;

public interface ICarDao {

    /**
     * 查询所有用户数量
     *
     * @return
     */
    @Select("select * from tb_car where members_id=#{members_id}" )
    List<Car> findAll(Integer members_id);

    /**
     * 查询所有订单
     *
     * @param page 分页实体类
     * @return
     */
    @Select("select * from tb_car where goods_status like #{page.query} || goods_num like #{page.query} and flag = 0 limit #{page.num},#{page.size}")
    List<Car> findAll1(@Param("page") Page page);

    /**
     * 查询所有订单数量
     *
     * @return
     */
    @Select("select count(*) from tb_car")
    Integer findTotal();

    /**
     * 添加用户
     *
     * @param
     * @return
     */
    @Insert("insert into tb_car (members_id,goods_num,goods_id,goods_name,goods_price,goods_small_logo,nickname,address,tel,goods_status)" +
            " values(#{members_id},#{goods_num},#{goods_id},#{goods_name},#{goods_price}," +
            "#{goods_small_logo},#{nickname},#{address},#{tel},#{goods_status})")
    @SelectKey(keyColumn = "id", keyProperty = "id", resultType = Integer.class,
            before = false, statement = {"select last_insert_id()"})
    Integer add(Car car);


    /**
     * 删除用户
     *
     * @param id 用户编号
     * @return
     */
    @Delete("delete from tb_car where id = #{id}")
    Integer del(Integer id);
    /**
     * 更新
     * @param car 用户编号
     * @return
     */
    @Update("update tb_car set goods_status=#{goods_status} where id=#{id}")
    Integer update(Car car);

    @Update("update tb_car set address=#{address},nickname=#{nickname},tel=#{tel} where id=#{id}")
    Integer update1(Car car);


}
